<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class GroupAcess_m extends MY_Model
{

    const TBL = 'auth_group_access';
	function __construct ()
	{
		parent::__construct();
	}


    public function get_groups_by_uid($uid){

        $sql = "SELECT uid,group_id,title,rules FROM {$this->db->dbprefix}auth_group_access a left join {$this->db->dbprefix}auth_groups g on a.group_id=g.id where a.uid='$uid' and g.status='1'";
        $query=$this->db->query($sql);
        if($query->num_rows() > 0){
            return $query->result_array();
        }
    }
    public function insert_user_access($data){
        return $this->db->insert('auth_group_access',$data);
    }
    public function update_user_access($uid,$data){
        $this->db->where('uid',$uid);
        $this->db->update('auth_group_access', $data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }

}
